const key = 'cookie'
// 获取cookie
function getSessionIDFromResponse(res) {
  var cookie = res.header['Set-Cookie']
  console.log('get cookie from response: ', cookie)
  return cookie
}

// 设置cookie
function setCookieToStorage(cookie) {
  try {
    console.log(cookie)
    wx.setStorageSync(key, cookie) // 设置缓存,设置cookie
  } catch (e) {
    console.log(e)
  }
}

function getCookieFromStorage() {
  var value = wx.getStorageSync(key)  // 获取当前缓存的cookie
  console.log(value)
  return value
}


module.exports = {
  setCookieToStorage: setCookieToStorage,
  getCookieFromStorage: getCookieFromStorage,
  getSessionIDFromResponse: getSessionIDFromResponse
}